package com.tz.colawallet.util;

import android.content.Context;

import com.bigkoo.alertview.AlertView;
import com.bigkoo.alertview.OnItemClickListener;
import com.jzxiang.pickerview.TimePickerDialog;
import com.jzxiang.pickerview.data.Type;
import com.jzxiang.pickerview.listener.OnDateSetListener;
import com.tz.colawallet.R;


/**
 * Created by admin on 2017/8/4.
 * <p>
 * 弹框设置
 */
public class AlertUtils {
    public interface AlertViewControl {
        void onItemClickListener(int position);
    }

    public static TimePickerDialog timePicker(Context context, int before, int after, OnDateSetListener listener) {
        return new TimePickerDialog.Builder()
                .setCallBack(listener)
                .setCancelStringId("取消")
                .setSureStringId("确定")
                .setTitleStringId("选择时间")
                .setYearText("年")
                .setMonthText("月")
                .setDayText("日")
                .setHourText("时")
                .setMinuteText("分")
                .setCyclic(false)
                .setMinMillseconds(System.currentTimeMillis() - 3600L * 1000 * 24 * before)
                .setMaxMillseconds(System.currentTimeMillis() + 3600L * 1000 * 24 * after)
                .setCurrentMillseconds(System.currentTimeMillis())
                .setThemeColor(context.getResources().getColor(R.color.timepicker_dialog_bg))
                .setType(Type.ALL)
                .setWheelItemTextNormalColor(context.getResources().getColor(R.color.timetimepicker_default_text_color))
                .setWheelItemTextSelectorColor(context.getResources().getColor(R.color.timepicker_toolbar_bg))
                .setWheelItemTextSize(12)
                .build();
    }

    public static TimePickerDialog timePicker2(Context context,String title, OnDateSetListener listener) {
        return new TimePickerDialog.Builder()
                .setCallBack(listener)
                .setCancelStringId("取消")
                .setSureStringId("确定")
                .setTitleStringId(title)
                .setYearText("年")
                .setMonthText("月")
                .setDayText("日")
                .setCyclic(false)
                .setMinMillseconds(System.currentTimeMillis() - 3600L * 1000 * 24 * 365 * 100)
                .setMaxMillseconds(System.currentTimeMillis())
                .setCurrentMillseconds(System.currentTimeMillis())
                .setThemeColor(context.getResources().getColor(R.color.timepicker_dialog_bg))
                .setType(Type.YEAR_MONTH_DAY)
                .setWheelItemTextNormalColor(context.getResources().getColor(R.color.timetimepicker_default_text_color))
                .setWheelItemTextSelectorColor(context.getResources().getColor(R.color.timepicker_toolbar_bg))
                .setWheelItemTextSize(12)
                .build();
    }

//    public static AlertView photoPicker(final Context context, final FunctionConfig functionConfig,
//                                        final GalleryFinal.OnHanlderResultCallback callback) {
//        return new AlertView.Builder().setContext(context)
//                .setStyle(AlertView.Style.ActionSheet)
//                .setTitle("选择操作")
//                .setMessage(null)
//                .setCancelText("取消")
//                .setDestructive("拍照", "从相册中选择")
//                .setOthers(null)
//                .setOnItemClickListener(new OnItemClickListener() {
//                    @Override
//                    public void onItemClick(Object o, int position) {
//                        String path = "";
//                        switch (position) {
//                            case 0:
//                                GalleryFinal.openCamera(Constants.REQUEST_CODE_CAMERA, functionConfig, callback);
//                                break;
//                            case 1:
//                                GalleryFinal.openGalleryMuti(Constants.REQUEST_CODE_GALLERY, functionConfig, callback);
//                                break;
//                            default:
//                                break;
//                        }
//                    }
//                })
//                .build();
//    }

    /**
     * 0-订单，1-会员卡
     *
     * @param context
     * @param control
     * @return
     */
    public static AlertView checkWhat(final Context context, final AlertViewControl control, String TitleInfo) {
        return new AlertView.Builder().setContext(context)
                .setStyle(AlertView.Style.ActionSheet)
                .setTitle("选择操作")
                .setMessage(null)
                .setCancelText("取消")
                .setDestructive(TitleInfo)
                .setOthers(null)
                .setOnItemClickListener(new OnItemClickListener() {
                    @Override
                    public void onItemClick(Object o, int position) {
                        control.onItemClickListener(position);
                    }
                })
                .build();
    }

    /**
     * 0-订单，1-会员卡
     *
     * @param context
     * @param control
     * @return
     */
    public static AlertView checkDoubleInfo(final Context context, final AlertViewControl control, String TitleInfo, String TitleInfo2, String TitleInfo3) {
        return new AlertView.Builder().setContext(context)
                .setStyle(AlertView.Style.ActionSheet)
                .setTitle("选择操作")
                .setMessage(null)
                .setCancelText("取消")
                .setDestructive(TitleInfo, TitleInfo2, TitleInfo3)
                .setOthers(null)
                .setOnItemClickListener(new OnItemClickListener() {
                    @Override
                    public void onItemClick(Object o, int position) {
                        control.onItemClickListener(position);
                    }
                })
                .build();
    }

}